<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- 
        1. 传统形式 --- 原型链
            过多的继承了没用的属性
        2. 借用构造函数
            不能继承借用构造函数原型
            每次构造函数都要多走一个函数
        3.共享原型
            不能随便改动自己的原型
        4.圣杯模式
     -->

    <script>
        // 1. 传统形式 --- 原型链
        Grand.prototype.lastName = "chen"
        function Grand() {

        }
        var grand = new Grand()

        Father.prototype = grand
        function Father() {

        }
        var father = new Father();

        Son.prototype = father
        function Son() {

        }
        var son = new Son()


        // 2. 借用构造函数
        function Person(name, age) {

        }

        function Student(name, age, grade) {
            Person.call(this, name, age)
            this.grade = grade;
        }
        var student = new Student();

        // 3.共享原型
        Son.prototype = Father.prototype;

        function inherit(Target, Origin) {
            Target.prototype = Origin.prototype
        }

        // 4.圣杯模式
        function Extend(Target, Origin) {
            function F() { }
            F.prototype = Origin.prototype;
            Target.prototype = new F()
            Target.prototype.constuctor = Target;
            Target.prototype.uber = Origin.prototype;
        }


        var inherit = (function () {
            var F = function () { };
            return function (Target, Origin) {
                F.prototype = Origin.prototype;
                Target.prototype = new F()
                Target.prototype.constuctor = Target;
                Target.prototype.uber = Origin.prototype;
            }
        })()


    </script>

</body>

</html>